var app=getApp();
var ux = require('../../../../lib/ux.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [
    ],
    next: true,
    page: 0,
    winHeight: 0,
    winWidth: 0,
    title: 'Hello',
    colorList: [
      '#ff0000', '#ff0033', '#ff3399', '#ff33cc', '#cc00ff', '#9900ff', '#cc00cc', '#cc0099', '#cc3399', '#cc0066',
      '#cc3300', '#CC6600', '#ff9933', '#ff9966', '#ff9999', '#ff99cc', '#ff99ff', '#cc66ff', '#9966ff', '#cc33ff',
      '#663300', '#996600', '#996633', '#cc9900', '#a58800', '#cccc00', '#ffff66', '#ffff99', '#ffffcc', '#ffcccc',
      '#336600', '#669900', '#009900', '#009933', '#00cc00', '#66ff66', '#339933', '#339966', '#009999', '#33cccc',
      '#003366', '#336699', '#3366cc', '#0099ff', '#000099', '#0000cc', '#660066', '#993366', '#993333', '#800000'
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var self=this;
    wx.getSystemInfo({
      success: function (res) {
        self.setData({
          winHeight: res.windowHeight,
          winWidth: res.windowWidth
        })
      }
    });
    this.getList();
  },
  getList: function () {
    var thats = this;
    wx.showLoading({
      title: "加载中...",
      mask: true
    })
    var obj = {
      page: this.data.page,
      size: 10
    }
    ux.request("/api/memberUser/getNotisLog.do", obj, function (data) {
      wx.hideLoading();
      if (data.data.list.length > 0) {
        var lists = data.data.list;
        var colors = thats.data.colorList;
        for (let i = 0; i < lists.length; i++) {
          lists[i].cl = colors[Math.floor((Math.random() * colors.length))];
        }
        thats.setData({
          next: data.data.pageInfo.next
        })
        if (thats.data.page == 0) {
          thats.setData({
            list: lists
          })
        } else {
          thats.setData({
            list: thats.data.list.concat(lists)
          })
        }
      }
    }, true);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },
  tabBScorll:function(){
    if (!this.data.bnext) {
      if(this.data.blists.length==0){
        this.msg("暂无消息!");
      }else{
        this.msg("没有更多了!");
      }
      return false;
    } else {
      this.setData({
        bpage: this.data.bpage + 1
      })
      this.getList();
    }
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})